# 员工管理api
import requests
import app


class UserAPI:
    def __init__(self):
        self.url_add = "http://ihrm2-test.itheima.net/hrsaas/employees"
        self.url_select = "http://ihrm2-test.itheima.net/api/sys/user/:"
        self.url_update = "http://ihrm2-test.itheima.net/api/sys/user/:"
        self.url_delete = "http://ihrm2-test.itheima.net/api/sys/user/:"

    # 添加
    def add(self, dic_user):
        return requests.post(url=self.url_add, json=dic_user, headers=app.headers_data)

    # 查询
    def select(self, user_id):
        return requests.post(url=self.url_select+user_id)

    # 修改
    def update(self, user_id, dic_user):
        return requests.put(url=self.url_update+user_id, json=dic_user)

    # 删除
    def delete(self, user_id):
        return requests.post(url=self.url_delete+user_id)
